package  com.pcbly.web.business.user;

/**
* @author carl.song
* Copyright (c) 2010 Lightsoft, International.
* All rights reserved.
*
*/

import java.util.HashMap;
import java.util.List;

import com.pcbly.web.persistence.user.UserWorkExperienceDao;
import com.pcbly.web.persistence.table.ColumnDao;
import com.pcbly.web.bean.user.UserWorkExperienceBean;
import com.pcbly.web.bean.table.ColumnBean;
import com.pcbly.web.business.BaseServiceImp;
import com.pcbly.web.components.hibernate.support.Page;
import com.pcbly.web.components.form.AbstractAnalyseCommonDataExt;
import com.pcbly.web.components.form.AnalyseCommonDataExtCreate;
import com.pcbly.web.components.form.AnalyseCommonDataExtEdit;
import com.pcbly.web.components.form.AnalyseCommonDataExtView;

 
public class UserWorkExperienceServiceImp extends BaseServiceImp<UserWorkExperienceBean> implements UserWorkExperienceService {
	 public UserWorkExperienceServiceImp() {
		super();
		// TODO Auto-generated constructor stub
	}
	private UserWorkExperienceDao userWorkExperienceDao;
	
	private ColumnDao columnDao;

	public void setColumnDao(ColumnDao columnDao) {
		this.columnDao = columnDao;
	}
	
	public void setUserWorkExperienceDao(UserWorkExperienceDao userWorkExperienceDao) {
		this.userWorkExperienceDao = userWorkExperienceDao;
	}
	
	@Override
	public UserWorkExperienceBean getUserWorkExperienceBeanById(String id) throws Exception {
		// TODO Auto-generated method stub
		return userWorkExperienceDao.get(UserWorkExperienceBean.class,id);
	}
	
	@Override
	public void removeUserWorkExperienceBeanById(String id) throws Exception{
		userWorkExperienceDao.removeUserWorkExperienceBeanById(id);
	}
	
	@Override
	public void removeUserWorkExperienceBeanByIds(String ids) throws Exception{
		userWorkExperienceDao.removeUserWorkExperienceBeanByIds(ids);
	}
	
	
	@Override
	public UserWorkExperienceBean saveUserWorkExperienceBean(UserWorkExperienceBean user) throws Exception{
		return userWorkExperienceDao.saveUserWorkExperienceBean(user);
	}
	
	@Override
	public UserWorkExperienceBean updateUserWorkExperienceBean(UserWorkExperienceBean user) throws Exception{
		userWorkExperienceDao.saveObject( user);
		return user;
	}
	public Page<UserWorkExperienceBean>  findUserWorkExperienceBeanByCond(UserWorkExperienceBean bean,
			Page<UserWorkExperienceBean> page, String orderByName, boolean asc)
			throws Exception{
		return userWorkExperienceDao.findUserWorkExperienceBeanByCond(
				bean, page, orderByName, asc);
	}
	
	@Override
	public String findUserWorkExperienceBeanExtCreate(String tableName) throws Exception {
		// TODO Auto-generated method stub
		List<ColumnBean> columnList = columnDao
				.findColumnBeansByTableName(tableName);
		AbstractAnalyseCommonDataExt common = new AnalyseCommonDataExtCreate();
		common.setColumnList(columnList);
		return common.execute().toString();
	}

	@Override
	public String findUserWorkExperienceBeanExtEdit(String tableName, String id)
			throws Exception {
		// TODO Auto-generated method stub
		List<HashMap<String, String>> dataList = userWorkExperienceDao
				.findCommnonDataBeanExt(tableName, id);
		List<ColumnBean> columnList = columnDao
				.findColumnBeansByTableName(tableName);
		AbstractAnalyseCommonDataExt common = new AnalyseCommonDataExtEdit();
		common.setDataList(dataList);
		common.setColumnList(columnList);
		return common.execute().toString();
	}

	@Override
	public String findUserWorkExperienceBeanExtView(String tableName, String id)
			throws Exception {
		// TODO Auto-generated method stub
		List<HashMap<String, String>> dataList = userWorkExperienceDao
				.findCommnonDataBeanExt(tableName, id);
		List<ColumnBean> columnList = columnDao
				.findColumnBeansByTableName(tableName);
		AbstractAnalyseCommonDataExt common = new AnalyseCommonDataExtView();
		common.setDataList(dataList);
		common.setColumnList(columnList);
		return common.execute().toString();
	}

	@Override
	public void saveUserWorkExperienceBeanExt(String sql) throws Exception {
		// TODO Auto-generated method stub
		userWorkExperienceDao.saveCommnonDataBeanExt(sql);
	}

	@Override
	public boolean getHasUserWorkExperienceBeanExtData(String tableName, String id)
			throws Exception {
		// TODO Auto-generated method stub
		return userWorkExperienceDao.getHasCommnonDataBeanExt(tableName, id);
	}
}
